package com.itbaizhan.controller;


import com.itbaizhan.enums.MembersInfoSexEnum;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class MembersInfoSexController {
    @RequestMapping("/findGender")
    public ModelAndView findBookType(HttpServletRequest request){
        HashMap<String,Object> hashMap = new HashMap<>();
        String id = request.getParameter("id");
        hashMap.put("id", id);
        hashMap.put("m", StringUtils.isNotBlank(id) ? "id查询成功" : "id查询失败");
        System.out.println(hashMap.get("m"));
        List<HashMap<String,Object>> MembersInfoSexEnumList = new ArrayList<>();
        for (MembersInfoSexEnum membersInfoSexEnum : MembersInfoSexEnum.values()) {
            HashMap<String,Object> map = new HashMap<>();
            map.put("name",membersInfoSexEnum.name());
            map.put("value",membersInfoSexEnum.getValue());
            MembersInfoSexEnumList.add(map);
        }
        ModelAndView modelAndView = new ModelAndView();
        Map<String, Object> model = modelAndView.getModel();
        model.put("MembersInfoSexEnumList",MembersInfoSexEnumList);
        model.put("map",hashMap);
        modelAndView.setViewName("updatePage");
        return modelAndView;
    }
}
